//
//  TTHMHomeRetweetView.swift
//  WeiBo
//
//  Created by 涂永江 on 2017/6/8.
//  Copyright © 2017年 涂永江. All rights reserved.
//

import UIKit
import SnapKit

class TTHMHomeRetweetView: UIView {

    var pictureContain:Constraint?
    // MARK:  -- 哈哈
    var stutesModel:TTStatuesViewModel?{
    
        didSet{
        
            contentLabel.text = stutesModel?.contensText
           
              pictureContain?.deactivate()
            if let pics = stutesModel?.statues?.retweeted_status?.pic_urls, pics.count > 0
            {
              
                    pictureColltionView.isHidden = false
                self.snp.makeConstraints({ (make) in
                    pictureContain = make.bottom.equalTo(pictureColltionView).offset(magin).constraint
                })
                
                 pictureColltionView.pics = stutesModel?.statues?.retweeted_status?.pic_urls
            }else
            {
                    pictureColltionView.isHidden = true
                    
                    self.snp.makeConstraints({ (make) in
                    pictureContain = make.bottom.equalTo(contentLabel).offset(magin).constraint
                    })
                    
                    
                }
            
        }
    
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    //  MARK:   --懒加载控件
    //  转发微博内容
    private lazy var contentLabel: UILabel = {
        let label = UILabel(fontSize: 13, textColor: UIColor.lightGray)
        label.text = "快可认识观看进度表v看电视到解放碑就电饭煲就是比较火不金山毒霸大家好北京市房博大精深方便就是狂拉升京东方"
        //  设置多行显示
        label.numberOfLines = 0
        return label
    }()
    // MARK: --懒加载colltionView
    private lazy var pictureColltionView:TTPictureCollection =  TTPictureCollection()
    
    
    func setUI()
    {
    
       addSubview(contentLabel)
       addSubview(pictureColltionView)
        contentLabel.snp.makeConstraints { (make) in
            make.top.equalTo(self)
            make.leading.equalTo(self).offset(magin)
            make.trailing.equalTo(self).offset((-magin))
        }
        
        pictureColltionView.snp.makeConstraints { (make) in
            make.top.equalTo(contentLabel.snp.bottom).offset(magin)
            make.leading.equalTo(contentLabel)
            make.size.equalTo(CGSize(width: 100, height: 100)).priority(.high)
        }
        
        //关键约束
      self.snp.makeConstraints { (make) in
       pictureContain = make.bottom.equalTo(pictureColltionView).offset(magin).constraint
        }
       
    }

}
